package main

import (
	"fmt"
	"time"
)

func main() {
	now := time.Now()
	later := now.Add(time.Hour * 2) //两小时后
	fmt.Println(now)                //不会改变
	fmt.Println(later)

	//时间比较
	if now.Equal(later) {
		fmt.Println("相等")
	} else {
		fmt.Println("不相等")
	}

	if now.Before(later) {
		fmt.Println("now在later 之前")
	}

	if later.After(now) {
		fmt.Println("later 在 now 之后")
	}
}
